package prv.pursuivant.config.impl;

import static org.junit.Assert.*;

import java.util.Iterator;
import java.util.List;

import org.junit.Test;

import prv.pursuivant.config.CategoryDesc;
import prv.pursuivant.config.Config;
import prv.pursuivant.core.AllToons;
import prv.pursuivant.core.Toon;
import prv.pursuivant.core.impl.ToonImpl;

import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.internal.Lists;

public class ConfigTest {

	@Test
	public void shouldGetActiveCategory() {
		Injector injector = Guice.createInjector(new ConfigTestModule());
		Config config = injector.getInstance(Config.class);
		final CategoryDesc activeCategory = config.getActiveCategory();

		assertEquals(CategoryDesc.DUNGEONS_AND_RAIDS, activeCategory.getId());
	}

	@Test
	public void shouldGetActiveAchievements() {
		Injector injector = Guice.createInjector(new ConfigTestModule());
		Config config = injector.getInstance(Config.class);
		List<String> activeAchievements = config.getActiveAchievements();

		assertEquals(Lists.newArrayList("2137", "2138"), activeAchievements);
	}

	@Test
	public void shouldGetToons() {
		Injector injector = Guice.createInjector(new ConfigTestModule());
		Config config = injector.getInstance(Config.class);
		AllToons toons = config.getToons();

		Iterator<Toon> iterator = toons.iterator();
		assertEquals(new ToonImpl("Kwinto", 3), iterator.next());
		assertFalse(iterator.hasNext());
	}

}
